package interview;

public class lc5 {
    public static void main(String[] args) {
        System.out.println(longestPalindrome("a"));
    }
    public static String longestPalindrome(String s) {
        String re = "";
        for (int i = 0; i < s.length(); i++) {
            String a = huiwen(i, i, s);
            if(a.length() > re.length())
                re = a;
            String b = huiwen(i, i + 1, s);
            if(b.length() > re.length())
                re = b;
        }
        return re;
    }
    public static String huiwen(int b, int e, String s){
        while (b >= 0 && e < s.length() && s.charAt(b) == s.charAt(e)){
            b--;
            e++;
        }
        return s.substring(b + 1, e);

    }
}
